/**
 * Project: common2
 * <p>
 * File Created at 2015年8月8日
 * <p>
 * Copyright 2015 Ledong.com Croporation Limited.
 * All rights reserved.
 * <p>
 * This software is the confidential and proprietary information of
 * Ledong Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Ledong.com.
 */
package com.jiangyao.common.utils;

import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.nio.charset.Charset;

/**
 * base 64 加密解密
 *
 * @author yangyongchuan
 * @version 1.0.0 2020年8月8日 下午1:04:55
 */
public class Base64Util {
	private final static Logger LOGGER = LoggerFactory.getLogger(Base64Util.class);

	public static byte[] decode(String content) {
		try {
			return Base64.decodeBase64(content);
		} catch (Exception e) {
			LOGGER.error(e.getMessage(), e);
		}
		return null;
	}

	public static String decode2Str(String content) {
		try {
			return new String(Base64.decodeBase64(content), Charset.defaultCharset());
		} catch (Exception e) {
			LOGGER.error(e.getMessage(), e);
		}
		return null;
	}

	public static String encode(byte[] content) {
		return Base64.encodeBase64String(content);
	}


}
